package com.itheima.night.demo01;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

//Executors默认线程池
public class NewFixedThreadPoolDemo01 {
    public static void main(String[] args) {
        ExecutorService executorService = null;
        ThreadPoolExecutor pool = null;
        try {
            executorService = Executors.newFixedThreadPool(10);
            pool = (ThreadPoolExecutor) executorService;
            for (int i = 0; i < 11; i++) {
                executorService.submit(new MyRunnable());
                executorService.shutdown();
            }
        } catch (Exception e) {
            System.out.println("线程太多了，出BUG了");
        }
        System.out.println(pool.getPoolSize());
    }
}
